package dm;

/**
 * <p>Title: Domain Model Generator</p>
 *
 * <p>Description: Automatic generation of a domain model</p>
 *
 * <p>Copyright: Copyright (c) 2011</p>
 *
 * <p>Company: UTA</p>
 *
 * @author David Kung
 * @version 1.0
 */
public class VerbPlusEd
    extends DMComp {
  public VerbPlusEd(String fileName, String leftMarker) {
    super(fileName, leftMarker);
  }
  public int indexOf(String content, String item) {
    String itemPlusEd=(item.toLowerCase().endsWith("e"))?item+"d":
        item+"ed";
    int k=content.toLowerCase().indexOf(" "+itemPlusEd.toLowerCase()+" ");
    if (k>=0) return k;
    k=content.toLowerCase().indexOf(itemPlusEd.toLowerCase()+" ");
    if (k==0) return k; else return -1;
  }
  public String markIt(String s) {
    return "<VD "+s+"> ";
  }
  public boolean checkNMark(Segment p) {
    String content = p.getContent();
    for (int j = 0; j < theList.size(); j++) {
      String item = (String) theList.get(j);
      int k = indexOf(content, item);
      if (k<0) {
        String[] s=tryThese(item);
        for(int i=0; i<s.length; i++) {
          k=indexOf(content, s[i]);
          if (k>=0) {
            item = s[i];
            break;
          }
        }
      }
      if (k>=0) {
        split(p, k, k + item.length()+2);
        return true;
      }
    }
    return false;
  }

  public static void main (String[] args) {
    VerbPlusEd vpe=new VerbPlusEd("dict/transverbs.txt", "<VD");
    String s="";
    for(int i=0; i<args.length; i++) s += args[i]+" ";
    Segment sgmt=new Segment(s, false, null);
    vpe.annotate(sgmt);
    System.out.println("result="+sgmt.content);
  }
}
